﻿namespace SecondClassAssignment{
    public class Account{
        private string _id;
        private string _pwd;
        private double _balance;

        public Account(){
        }

        public Account(string id, string pwd, double balance){
            _id = id;
            _pwd = pwd;
            _balance = balance;
        }

        public Account(string id, string pwd){
            _id = id;
            _pwd = pwd;
        }

        public string Id{
            get => _id;
            set => _id = value;
        }

        public string Pwd{
            get => _pwd;
            set => _pwd = value;
        }

        public double Balance{
            get => _balance;
            set => _balance = value>0 ? value : 0;
        }

        protected bool Equals(Account other){
            return _id == other._id;
        }

        public override bool Equals(object obj){
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((Account)obj);
        }

        public override int GetHashCode(){
            return _id.GetHashCode();
        }
    }
}